﻿using EM.OA.BLL;
using EM.OA.DataModel.DBModel;
using EM.OA.WebCommon.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Web;
namespace EM.OA.Portal.Models
{
    public class SignConfigModels : BaseViewModel
    {
        /// <summary>
        /// 考勤配置表ID
        /// </summary>		
        [Display(Name = "考勤配置表ID")]
        public Guid? SignConfigID { get; set; }
        /// <summary>
        ///  考勤名称
        /// </summary>		
        [Display(Name = "考勤名称")]
        public string SignName { get; set; }
        /// <summary>
        /// 记录周几工作；
        ///例如 ： 1,2,3,4,5 表示周一到周五工作；
        /// </summary>		
        [Display(Name = "工作日")]
        public string WeekDays { get; set; }

        /// <summary>
        /// 上班打卡时间有个范围 8点上班，7点~9点之间可以打卡；偏移量就是1个小时;单位为分钟
        /// </summary>		
        [Display(Name = "上班打卡偏移时间")]
        public int OpenOffset { get; set; }
        /// <summary>
        /// 下班打卡偏移时间
        /// </summary>		
        [Display(Name = "下班打卡偏移时间")]
        public int CloseOffset { get; set; }
        /// <summary>
        /// 备注
        /// </summary>		
        [Display(Name = "备注")]
        public string Remark { get; set; }

        /// <summary>
        /// 考勤明细上班时间Json数据
        /// </summary>
        public string JsonConfigDetail { get; set; }

        public string WorkTime { get {
            string time = string.Empty;

            if (SignConfigID.HasValue)
            {
                List<EMOA_SignConfigDetail> list = new List<EMOA_SignConfigDetail>();

                list = new SignConfigDetailBLL().GetList(p => p.SignConfigID == SignConfigID, p => p.WorkBeginTime);

                list.ForEach(p => {
                    time += p.WorkBeginTime.ToShortTimeString() + "～" + p.WorkEndTime.ToShortTimeString() + "<br/>";
                });
            }
            return time;
        } }

    }
}